﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

/*
* 泰波那契序列 Tn 定义如下： 
	
T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2
								n =	3		Tn = Tn-1 + Tn-2 + Tn-3
给你整数 n，请返回第 n 个泰波那契数 Tn 的值

*/
int tribonacci(int n)
{
	if (n == 0)
		return 0;
	if (n == 1 || n == 2)
		return 1;
	int a = 0, b = 1, c = 1, d = 0;
	for (int i = 3; i <= n; i++)
	{
		d = a + b + c;
		a = b;
		b = c;
		c = d;
	}
	return d;
}
int main()
{
	int n = 0;
	scanf("%d", &n);
	int ret = tribonacci(n);
	printf("%d", ret);
	return 0;
}